package com.bwie.serverdemojdk17.service.impl;

import com.bwie.serverdemojdk17.entity.TbAsk;
import com.bwie.serverdemojdk17.entity.TbUser;
import com.bwie.serverdemojdk17.mapper.primary.TbUserMapper;
import com.bwie.serverdemojdk17.mapper.secondary.TbAskMapper;
import com.bwie.serverdemojdk17.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/11/4 19:02
 */

@Service
public class TestServiceImpl implements TestService {

    // 注入主数据源的Mapper
    @Autowired
    private TbUserMapper primaryUserMapper;

    // 注入第二个数据源的Mapper
    @Autowired
    private TbAskMapper secondaryUserMapper;

    @Override
    public Object getList() {

        HashMap<String, Object> map = new HashMap<>();

        List<TbUser> tbUsers = primaryUserMapper.selectList(null);
        map.put("tbUsers", tbUsers);

        List<TbAsk> tbAsks = secondaryUserMapper.selectList(null);
        map.put("tbAsks", tbAsks);

        return map;
    }
}
